<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" template="/template/template.xhtml"
	xmlns:s="http://sduept.security.el/func">
	<ui:define name="head">
		<link rel="stylesheet"
			href="/resources/plugins/datatables/dataTables.bootstrap.css" />
		<style>
			.ui-treetable-scrollable-header-box {
			    margin-left: 0px;
			    margin-right: 15px !important;
			}
		</style>
	</ui:define>
	<ui:define name="content">
		<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
			<p:commandButton value="是" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
			<p:commandButton value="否" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
		</p:confirmDialog>
		<div id="headDiv" class="box box-solid with-border">
			<h:form id="headForm">
				<p:growl id="msgs" showDetail="true" />
				<div id="toolbarDiv">
					<p:toolbar id="toolbar">
						<f:facet name="left">
							<p:commandButton value="新增" icon="ui-icon-plus" oncomplete="PF('editDlg').show()" update="headForm:msgs editForm :form:dataTb" 
								actionListener="#{inspectionEquipmentMaintenanceController.preCreate}" 
								disabled="#{inspectionEquipmentMaintenanceController.selected.parent!=null}"
								rendered="#{s:hasPermission(session,'dwfxpg_sbyhgl_jcsjzd_jcsbwh_xz')}" />
							<p:commandButton value="编辑" icon="ui-icon-pencil" oncomplete="PF('editDlg').show()" update="headForm:msgs editForm :form:dataTb"
								disabled="#{inspectionEquipmentMaintenanceController.selected==null}" 
								actionListener="#{inspectionEquipmentMaintenanceController.preEdit}" 
								rendered="#{s:hasPermission(session,'dwfxpg_sbyhgl_jcsjzd_jcsbwh_bj')}" />
							<p:commandButton value="删除" icon="ui-icon-trash" update="headForm:msgs headForm:toolbar :form:dataTb"
								disabled="#{inspectionEquipmentMaintenanceController.selected==null}"
								actionListener="#{inspectionEquipmentMaintenanceController.delete}" 
								rendered="#{s:hasPermission(session,'dwfxpg_sbyhgl_jcsjzd_jcsbwh_sc')}" >
								<p:confirm message="该记录及其下的子记录均被删除，确定要删除么？" icon="ui-icon-alert" header="提示"/>
							</p:commandButton>
						</f:facet>
					</p:toolbar>
				</div>
			</h:form>
		</div>
		<div class="box box-solid with-border">
			<h:form id="form">
				<p:treeTable id="dataTb" widgetVar="dataTb" emptyMessage="无记录"
					value="#{inspectionEquipmentMaintenanceController.root}" selectionMode="single" 
					var="item" scrollable="true" scrollHeight="740">
					<p:ajax event="select" update="headForm:toolbar" listener="#{inspectionEquipmentMaintenanceController.onNodeSelect}" />
					<p:ajax event="expand" update="dataTb" listener="#{inspectionEquipmentMaintenanceController.onNodeExpand}" />
					<p:column headerText="名称">
						<h:outputText value="#{item.name}" />
					</p:column>
				</p:treeTable>
			</h:form>
			<h:form id="editForm">
				<p:dialog widgetVar="editDlg" modal="true" id="editDlg" width="500" height="200"
					header="#{inspectionEquipmentMaintenanceController.create.id!=null ? '编辑':'新建'}">
					<p:toolbar>
						<f:facet name="left">
							<p:commandButton value="保存" style="float: right;" icon="fa fa-floppy-o"
								actionListener="#{inspectionEquipmentMaintenanceController.save()}"
								oncomplete="PF('editDlg').hide()" update=":headForm:msgs :headForm:toolbar :form:dataTb"/>
						</f:facet>
					</p:toolbar>
					<p:panelGrid style="width:100%">
						<p:row>
							<p:column>
								<h:outputLabel value="内容" />
							</p:column>
							<p:column>
								<p:inputText value="#{inspectionEquipmentMaintenanceController.create.name}" style="width:98%"/>
							</p:column>
						</p:row>
					</p:panelGrid>
				</p:dialog>
			</h:form>
		</div>
	</ui:define>
	<ui:define name="contentend">
		<script src="/resources/js/tables/singleScrollTreeTable.js"></script>
	</ui:define>
</ui:composition>
